package com.ict.dataprocess;

import java.io.IOException;
import java.util.Arrays;

import com.ict.config.Config;
import com.ict.utils.ConnMQUtil;
import com.ict.utils.ConnRedisUtil;
import com.rabbitmq.client.ConsumerCancelledException;
import com.rabbitmq.client.QueueingConsumer;
import com.rabbitmq.client.ShutdownSignalException;

import team.iOceanPlus.PB.Target;

public class FuseReceiveMainMQThread extends Thread {
	public void run() {
        /**一次接受10个PB，已list方式存入redis中*/
		 while(true) {
			String[] arrRoutingKey = {Config.fuseTargetRoutingKey};
			ConnMQUtil connMQUtil = new ConnMQUtil();
			try {
				QueueingConsumer.Delivery delivery = connMQUtil.recv("topic", Config.recvExChangeName, arrRoutingKey, "xgs_tap_by_tlc");
				byte [] bytmessage=delivery.getBody();
				//Target.PBTarget test= Target.PBTarget.parseFrom(bytmessage);
				//ConnRedisUtil.jedis.hset("recv_fuse_pb".getBytes(), ("field"+x).getBytes(), bytmessage);
				ConnRedisUtil.jedis.lpush("recv_fuse_pb".getBytes(), bytmessage);
				//Target.PBTarget info = Target.PBTarget.parseFrom(delivery.getBody());
				//ConnMQUtil.recvChannel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
			} catch (ShutdownSignalException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (ConsumerCancelledException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		}
	}

}
